﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package com.fminutes.vinciDll {
    import flash.utils.*;
    import com.fminutes.vinciDll.analyze.*;
    import flash.net.*;
    import com.fminutes.vinciLib.utils.*;

    public class DllLoader extends MultiLoader {

        private var libAnalyze:LibAnalyze;
        private var _reload:int;

        public function DllLoader(){
            this._reload = 0;
        }
        override protected function currentComp(_arg1:int, _arg2:Object):void{
            var _local9:String;
            var _local11:CRC32;
            var _local12:String;
            var _local3:DllFileObject = (fileArr[_arg1] as DllFileObject);
            var _local4:String = _local3.url;
            var _local5:Array = _local4.split("/");
            var _local6:String = _local3.url;
            var _local7:Array = String(_local5[(_local5.length - 1)]).split("__");
            var _local8:String = String(_local7[(_local7.length - 1)]).split(".")[0];
            if (_local7.length == 1){
                _local9 = _local8;
            } else {
                _local11 = new CRC32();
                _local11.update((_arg2 as ByteArray));
                _local9 = _local11.getValue().toString(16);
            };
            if (_local8 != _local9){
                if (this._reload < 2){
                    _local12 = new Date().getTime().toString();
                    SharedObjectUtil.fmWriteSharedObject(_local6, _local12);
                    this.loadItem();
                    this._reload++;
                    return;
                };
            };
            this._reload = 0;
            var _local10:AnalyzeBase = (AnalyzeDictionary.getInstance().getAnalyze(_local3.type) as AnalyzeBase);
            if (!_local10){
                _local3.result = {};
                this.compFn();
                return;
            };
            _local10.analyze((_arg2 as ByteArray), _local3, this.compFn);
        }
        override protected function loadItem():void{
            var _local2:URLRequest;
            var _local1:DllFileObject = (fileArr[index] as DllFileObject);
            var _local3:String = SharedObjectUtil.fmReadSharedObject(_local1.url);
            if (_local3 != ""){
                _local2 = new URLRequest(((_local1.url + "?") + _local3));
            } else {
                _local2 = _local1.urlRequest;
            };
            loader.load(_local2);
            (fileArr[index] as DllFileObject).status = DllFileObject.LOADING;
        }
        private function compFn():void{
            if (!pause){
                next();
            };
        }
        public function addLoaderList(_arg1:Array):void{
            var _local3:int;
            var _local2:int;
            while (_local2 < fileArr.length) {
                if (fileArr[_local2].status == DllFileObject.LOADING){
                    _local3 = 0;
                    while (_local3 < _arg1.length) {
                        fileArr.splice(((_local2 + _local3) + 1), 0, _arg1[_local3]);
                        _local3++;
                    };
                    break;
                };
                _local2++;
            };
        }

    }
}//package com.fminutes.vinciDll 
